ToolResultOutput

@Serializable
sealed class ToolResultOutput

Structured return type for Tool.toModelOutput. Replaces the flat String return per historical parity gap #14. Lets a tool supply EITHER a short plain-text summary OR a structured JSON payload OR a typed error to the model — the agent's loop bridges each into the wire-format ContentPart.ToolResult.modelVisible appropriately:

  • Text → JsonPrimitive(text), isError = false.

  • Json → the JsonElement as-is, isError = false.

  • Content → a list of model-visible content parts, isError = content.isError.

  • Error → JsonPrimitive("Error: $message"), isError = true.

Inheritors

Types

Link copied to clipboard
@Serializable
data class Content(val value: List<JsonElement>, val isError: Boolean = false) : ToolResultOutput
Link copied to clipboard
@Serializable
data class Error(val message: String) : ToolResultOutput
Link copied to clipboard
@Serializable
data class ErrorJson(val json: JsonElement) : ToolResultOutput
Link copied to clipboard
@Serializable
data class ExecutionDenied(val reason: String? = null) : ToolResultOutput
Link copied to clipboard
@Serializable
data class Json(val json: JsonElement) : ToolResultOutput
Link copied to clipboard
@Serializable
data class Text(val text: String) : ToolResultOutput

Functions

Link copied to clipboard
fun ToolResultOutput.toJsonElement(): JsonElement